package signRecord

import (
	"api/internal/svc"
	"api/internal/types"
	"context"
	"user_srv/userclient"

	"github.com/zeromicro/go-zero/core/logx"
)

type RetroactiveSignInLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewRetroactiveSignInLogic(ctx context.Context, svcCtx *svc.ServiceContext) *RetroactiveSignInLogic {
	return &RetroactiveSignInLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *RetroactiveSignInLogic) RetroactiveSignIn(req *types.RetroactiveSignIn) (resp *types.Response, err error) {
	in, err := l.svcCtx.UserRpc.RetroactiveSignIn(l.ctx, &userclient.RetroactiveSignInRequest{ //补签某一天
		UserId: int64(req.UserId),
	})

	if err != nil {
		return &types.Response{
			Code:    400,
			Message: err.Error(),
			Data:    nil,
		}, nil
	}

	return &types.Response{
		Code:    200,
		Message: "补签成功",
		Data:    in,
	}, nil
}
